<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/layui/css/layui.css" media="all">

</head>
<body>

<div>
    <button type="button" class="layui-btn" id="upload">
        <i class="layui-icon">&#xe67c;</i>上传文件
    </button>
</div>
<div>
    <table id="demo" lay-filter="test"></table>
</div>
<script src="/layui/layui.js"></script>


<script>
    layui.use(['upload', 'table'], function () {
        var table = layui.table;
        var cols = [ //表头
            {field: 'status', title: '状态'},
            {field: 'version', title: '版本'},
            {field: 'oriname', title: '文件名'},
            {field: 'filesize', title: '文件大小'},
            {field: 'createtime', title: '上传时间'}
        ];
        //执行渲染
        table.render( {
            elem: '#demo', //指定原始表格元素选择器（推荐id选择器）
            response: {
                statusName: 'code' //规定数据状态的字段名称，默认：code
                , statusCode: 200 //规定成功的状态码，默认：0
                , msgName: 'message' //规定状态信息的字段名称，默认：msg
                , dataName: 'data' //规定数据列表的字段名称，默认：data
            }
            , url: "/clientver/list"
            , cols: [
                cols
            ]
        } );

        var upload = layui.upload;

        //执行实例
        var uploadInst = upload.render( {
            elem: '#upload' //绑定元素
            , exts: 'deb'
            , url: '/clientver/uploadVersion' //上传接口
            , done: function (res) {
                //上传完毕回调
                alert("上传完毕")
                location.reload();
            }
            , error: function () {
                //请求异常回调
                alert("上传失败")
            }
        } );
    });
</script>
</body>
</html>